import http from "@/common/http/request";
import {
  musicSongListInterface,
  musicSongAddInterface,
  musicSongUpdateInterface,
  musicSongDisMelodyAnalysisInterface,
  musicSongMelodyAnalysisInterface,
} from "./song.interface";

// 曲谱列表
export const $musicSongList = (data: musicSongListInterface) => {
  const $http = new http();
  return $http.get({
    url: '/music/song/list',
    data,
  })
}

// 曲谱详情
export const $musicSongDetail = (id: string) => {
  const $http = new http();
  return $http.get({
    url: `/music/song/${id}`,
  })
}

// 新增曲谱
export const $musicSongAdd = (data: musicSongAddInterface) => {
  const $http = new http();
  return $http.post({
    url: '/music/song',
    data,
  })
}

// 修改曲谱
export const $musicSongUpdate = (data: musicSongUpdateInterface) => {
  const $http = new http();
  return $http.put({
    url: '/music/song',
    data,
  })
}

// 非旋律打谱,(本质为修改曲谱中的非旋律谱字段)
export const $musicSongDisMelodyAnalysis = (data: musicSongDisMelodyAnalysisInterface) => {
  const $http = new http();
  return $http.put({
    url: '/music/song/disMelodyAnalysis',
    data,
  })
}

// 旋律打谱,(本质为修改曲谱中的旋律谱字段)
export const $musicSongMelodyAnalysis = (data: musicSongMelodyAnalysisInterface) => {
  const $http = new http();
  return $http.put({
    url: '/music/song/melodyAnalysis',
    data,
  })
}

// 删除曲谱
export const $musicSongDelete = (data: Array<string>) => {
  const $http = new http();
  return $http.delete({
    url: `/music/song/${data.join(',')}`,
  })
}

// 提交审核
export const $musicSongApproveSubmit = (id: number) => {
  const $http = new http();
  return $http.put({
    url: `/music/song/approve/submit/${id}`,
    data: {},
  })
}

// 作废审核
export const $musicSongApproveReback = (id: number) => {
  const $http = new http();
  return $http.put({
    url: `/music/song/approve/reback/${id}`,
    data: {},
  })
}

// 审核通过
export const $musicSongApprovePass = (id: number) => {
  const $http = new http();
  return $http.put({
    url: `/music/song/approve/pass/${id}`,
    data: {},
  })
}

// 审核不通过
export const $musicSongApproveUnpass = (id: number) => {
  const $http = new http();
  return $http.put({
    url: `/music/song/approve/unpass/${id}`,
    data: {},
  })
}

// 曲谱上架
export const $musicSongStock = (id: number) => {
  const $http = new http();
  return $http.put({
    url: `/music/song/stock/${id}`,
    data: {},
  })
}

// 曲谱下架
export const $musicSongUnStock = (id: number) => {
  const $http = new http();
  return $http.put({
    url: `/music/song/unStock/${id}`,
    data: {},
  })
}